function jsonSelectTree(settings){
	this.selectUlId = "jsonTreeSelect";
	if(settings.selectUlId!=null){
		this.selectUlId = settings.selectUlId;
	}
	this.jsonData = settings.jsonData;
	this.mcInputId = settings.mcInputId;
	this.idInputId = settings.idInputId;
	this.contentDivId = settings.contentDivId;
	var _this = this;
	
	this.fnOnClick = function(e, treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj(_this.selectUlId),
		nodes = zTree.getCheckedNodes(),
		v = "";
		n = "";
		//nodes.sort(function compare(a,b){return a.id-b.id;});
		for (var i=0; i<nodes.length; i++) {
			if(!nodes[i].getCheckStatus().half){
				v += nodes[i].name + ",";
				if(nodes[i].id != ""){
					n += nodes[i].id + ",";
				}
			}
		}
		if (v.length > 0 ){
		 	v = v.substring(0, v.length-1);
		 	n = n.substring(0, n.length-1);
		}
		var hyObj = $("#"+_this.mcInputId);
		hyObj.attr("value", v);
		//hidden jg_dm
		$("#"+_this.idInputId).attr("value", n);
		$("#"+_this.idInputId).change();
		//this.hideZdhyMenu();
	};
	
	this.fnOnAsyncSuccess = function(e, treeId, treeNode,msg){
		var name = $("#"+_this.mcInputId).val();
		var id = $("#"+_this.idInputId).val();
		var zTree_Menu = $.fn.zTree.getZTreeObj(_this.selectUlId);
		var nodes = zTree_Menu.transformToArray(zTree_Menu.getNodes());
		if(nodes.length>0){
			for(var i=0; i<nodes.length; i++){
				if(id.indexOf(nodes[i].id)>=0 && name.indexOf(nodes[i].name)>=0){
					nodes[i].checked = true;
					if(nodes[i].getParentNode()!=null){
						nodes[i].getParentNode().checked=true;
					}
					zTree_Menu.updateNode(nodes[i]);
				}
			}
		}
		
	};
	
	this.setting6 = {
		data: {
			simpleData: {
				enable: true
			}
		},
		async: {
			enable: true,
			url:'',
			autoParam:[],
			otherParam:{},
			dataFilter: null
		},
		callback: {
			onCheck: this.fnOnClick//,
			//onAsyncSuccess: this.fnOnAsyncSuccess
		},
		check:{
			enable:true,
			chkStyle:"checkbox"
		},
		view:{
			
		}
	};
	_this = this;
	
	this.getJsonTree = function(){
		$(document).ready(function(){
			$.fn.zTree.init($("#"+_this.selectUlId), _this.setting6,_this.jsonData);
		});
		this.showJsonTreeMenu();
		this.fnOnAsyncSuccess();
	};
	
	this.showJsonTreeMenu = function(){
		var orgObj = $("#"+this.mcInputId);
		var orgOffset = $("#"+this.mcInputId).offset();
		$("#"+this.contentDivId).css({left:orgOffset.left + "px", top:orgOffset.top 
			+ orgObj.outerHeight() + "px"}).slideDown("fast");
		
		$("body").bind("mousedown", this.onJsonTreeBodyDown);
	};
	
	this.onJsonTreeBodyDown = function(event){
		if (!(event.target.id == _this.mcInputId || event.target.id == _this.contentDivId || $(event.target).parents("#"+_this.contentDivId).length>0)) {
			_this.hideZdhyMenu();
		}
	};
	
	this.hideZdhyMenu = function(){
		$("#"+_this.contentDivId).fadeOut("fast");
		$("body").unbind("mousedown",this.onJsonTreeBodyDown);
	};

	
	
	
	
	
	
}
